﻿@{
    Layout = null;
}
<script src="~/Content/js/AjaxSuccess.js"></script>
@{
    MODEL.user UserInfo = ViewData["UserInfo"] as MODEL.user;

    if (UserInfo != null)
    {
    <div id="LoginOut">
        <div class="am-topbar-right" id="login">
            <ul class="am-nav am-nav-pills am-topbar-nav">
                <li class="am-dropdown" data-am-dropdown>
                    <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;"><i class="am-icon-user"></i> @UserInfo.user_eName <span class="am-icon-caret-down"></span>
                    </a>
                    <ul class="am-dropdown-content">
                        <li><a href="#"><i class="am-icon-lock"></i> 我的资料 </a></li>
                        <li><a href="#"><i class="am-icon-heart"></i> 我的收藏 </a></li>
                        <li><a href="#"><i class="am-icon-graduation-cap"></i> 正在学习 </a></li>
                        <li><a href="#"><i class="am-icon-users"></i> 我的讨论组 </a></li>
                        <li><a href="javascript:LoginOut()"><i class="am-icon-power-off"></i> 注销 </a></li>
                    </ul>
                </li>
            </ul>
        </div>

    </div>
    <script>
        function LoginOut() {
            $.ajax({
                type: 'post',
                url: '@Url.Action("LoginOut", "User")',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        AjaxSuccessUrlAndMsg(data);
                    }
                });
            }
    </script>
    }
    else
    {
    <div id="LoginInfo">
        <div class="am-topbar-right">
            <a class="am-btn  am-topbar-btn" href="@Url.Action("Regist", "User")">注册</a>
        </div>
        <div class="am-topbar-right">
            <button type="button" class="am-btn am-btn-primary js-modal-open am-topbar-btn">登陆</button>
            <div class="am-modal am-modal-no-btn" tabindex="-1" id="your-modal">
                <div class="am-modal-dialog">
                    <div class="am-modal-hd" style="margin-bottom: 5%;">
                        登陆窗口
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
                    </div>
                    <div class="am-modal-bd">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="doc-ipt-3" class="am-u-sm-2 am-form-label">电邮</label>
                                <div class="am-u-sm-10">
                                    <input type="email" id="doc-ipt-3" placeholder="输入你的电子邮件" name="LoginEmail">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="doc-ipt-pwd-2" class="am-u-sm-2 am-form-label">密码</label>
                                <div class="am-u-sm-10">
                                    <input type="password" id="doc-ipt-pwd-2" placeholder="输入你的密码" name="LoginPwd">
                                </div>
                            </div>

                            <div class="am-form-group" style="margin-top: 10%;">
                                <div class="am-u-sm-7">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" value="yes" name="IsAlway">
                                            记住十万年
                                        </label>
                                    </div>
                                </div>
                                <div class="am-u-sm-5">
                                    <button type="button" id="LoginSubmit" class="am-btn am-btn-default  btn-loading-example">提交登入</button>
                                </div>

                            </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script type="text/javascript">
        function Loading(obj) {
            var $btn = obj;
            $btn.button('loading');
            setTimeout(function () {
                $btn.button('reset');
            }, 5000);
        }
        $(function () {
            $("#LoginSubmit").click(function () {
                $.ajax({
                    type: 'post',
                    url: '@Url.Action("LoginInfo", "User")',
                    data: { Email: $("input[name='LoginEmail']").val(), Pwd: $("input[name='LoginPwd']").val(), IsAlway: $("input[name='IsAlway']").val() },
                    cache: false,
                    dataType: 'json',
                    before: Loading($(this)),
                    success: function (data) {
                        AjaxSuccessUrlAndMsg(data);
                    }
                });

            });
        });
    </script>
    }
}
